qinglan.Canvas.BulletHelper = qinglan.Canvas.Class(function(id, opt){
	this.id = id;

	this.sprite = null;

	this.map = {};

	this.from = {};

	this.mapStatus = {};

	this.opt = qinglan.Extend.simple({
		equal: qinglan.Tween.Quadratic.easeInOut,
		duration: 5000,
		delay: 150,
		type: 'to'
	}, opt, 1);

	this.data = qinglan.Canvas.TweenData.createData();

	this.listener = new qinglan.Listener('$bulletHelper_' + id, this);

}).methods({
	init: function(){

	},
	initData: function(){
		throw 'The setMap function must be implemented!';
	},
	setMap: function(from, to){
		this.from = from;
		this.map = to;
	},
	pause: function(){
		if(!this.data.isplay){return false;}
		this.data.ispaused = true;
		this.data.isplay = false;
		this.data.init = false;
		this.listener.notify('pause');
		return true;
	},
	resume: function(){
		if(this.data.isplay){return false;}
		this.data.ispaused = false;
		this.data.isplay = true;
		this.listener.notify('resume');
		return true;
	},
	setSprite: function(sprite) {
		this.sprite = sprite;
	},
	update: function(){
		throw 'The update function must be implemented!';
	},
	destory: function(){
		throw 'The destory function must be implemented!';
	}
}).statics({
	calculate: function(from, to, type){
		var begin = {};
		var sub = {};
		var mapLen = 0;
		qinglan.Object.each(to,function(val,key){
			if('to' == type){
				begin[key] = from[key] || 0;
				sub[key] = val - begin[key];
			}else{
				begin[key] = val;
				sub[key] = from[key] - begin[key];
			}
			mapLen++;
		});
		return {
			sub: sub,
			begin: begin,
			mapLen: mapLen
		};
	}
});
